//
//  loginTextField.m
//  FastRunDemo
//
//  Created by 苟亚明 on 16/10/18.
//  Copyright © 2016年 苟亚明. All rights reserved.
//

#import "loginTextField.h"

static NSString * const GYMPlacerholderColorKeyPath = @"_placeholderLabel.textColor";
static NSString * const GYMPlacerholderFontColorKeyPath = @"_placeholderLabel.font";
@implementation loginTextField


- (void)awakeFromNib
{
    // 设置光标颜色和文字颜色一致
    self.tintColor = self.textColor;
    
    // 不成为第一响应者
    [self resignFirstResponder];

}

/**
 * 当前文本框聚焦时就会调用
 */
- (BOOL)becomeFirstResponder
{
    // 修改占位文字颜色
//    [self setValue:self.textColor forKeyPath:GYMPlacerholderColorKeyPath];
    [self setValue:[UIFont systemFontOfSize:12] forKeyPath:GYMPlacerholderFontColorKeyPath];
    return [super becomeFirstResponder];
}

/**
 * 当前文本框失去焦点时就会调用
 */
- (BOOL)resignFirstResponder
{
    
    [self setValue:[UIFont systemFontOfSize:12] forKeyPath:GYMPlacerholderFontColorKeyPath];
    // 修改占位文字颜色
//    [self setValue:[UIColor grayColor] forKeyPath:GYMPlacerholderColorKeyPath];
    return [super resignFirstResponder];;
}

@end
